package com.kestrel.space.common.utils;

/**
 * @author yebolin
 * @date 2024/9/11
 */
public class MyStringUtils {
    public static String getFileNameByFileUrl(String fileUrl) {
        int lastSlashIndex = fileUrl.lastIndexOf('/');
        if (lastSlashIndex!= -1) {
            return fileUrl.substring(lastSlashIndex + 1);
        }
        return null;
    }

    public static String convertFileNameType(String fileName, String targetExtension) {
        int dotIndex = fileName.lastIndexOf('.');
        if (dotIndex!= -1) {
            String baseName = fileName.substring(0, dotIndex);
            return baseName + targetExtension;
        } else {
            return fileName + targetExtension;
        }
    }
}
